package com.sunb2b.util;

public class IDUtils {
    public static String getNextId(String id){
        if(id.length()%3!=0){
            throw new RuntimeException("Invalid id "+ id +" in IDUtils");
        }
        
        if(id.length()<3){
            throw new RuntimeException("Invalid id "+ id +" in IDUtils");
        }
        else{
            String part1 = id.substring(0, id.length()-3);
            String id1 = id.substring(id.length()-3);
            int idInt = Integer.parseInt(id1);
            if(idInt<100){
                throw new RuntimeException("Invalid id "+ id +" in IDUtils");
            }
            if(idInt==999){
                throw new RuntimeException("Invalid id "+ id +" in IDUtils");
            }
            idInt += 1;
            return part1 + idInt + "";
        }
    }
    
    public static void main(String [] args){
        String id = "100101789";
        System.out.println(getNextId(id));
    }
}
